<template>
  <div>
    <h1>个人信息</h1>
    <HR1/>
    <el-container class="col1">
      <h2>用户名：</h2>
      <p1>{{account}}</p1>
      <h3>账号：</h3>
      <p2>{{sid}}</p2>
      <h4>姓名：</h4>
      <p3>{{name}}</p3>
      <h5>性别：</h5>
      <p4>{{sex}}</p4>
      <h6>电话：</h6>
      <p5>{{tel}}</p5>
      <h7>个人邮箱：</h7>
      <p6>{{mail}}</p6>
    </el-container>
    <el-button class="button" @click="logout()">退出登录</el-button>
  </div>
</template>

<script>
import fetch from '../api/fetch'
export default {
  data() {
    return {
      sid: '',
      account: '',
      name: '',
      sex: '',
      tel: '',
      mail: '',
    }
  },
  mounted() {
    this.getStudentInfo(sessionStorage.getItem('userId'));
  },
  //this.loadChangeInfo();
  methods: {
    getStudentInfo(sid) {
      fetch.getStudentInfo(sid).then(res => {
        console.log(res)
        this.account = res.data.account;
        this.sid = res.data.sid;
        this.name = res.data.name;
        this.tel = res.data.tel;
        this.mail = res.data.mail;
        if (res.data.sex === 1) {
          this.sex = '女';
        } else {
          this.sex = '男';
        }
      })
    },
    logout() {
      console.log(sessionStorage.getItem('userId'))
      this.$router.push({name:'login'})
      sessionStorage.removeItem('userId')
      sessionStorage.removeItem('role')
    }
  }
}
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .col1{
    position: absolute;
    left:0px;
    height: 80px;

  }
h1 {
  position: absolute;
  left: 250px;
  top: 75px;
  width: 200px;
  height: 50px;
  color: rgba(16, 16, 16, 1);
  font-size: 25px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}
HR1 {
  position: absolute;
  left: 250px;
  top: 120px;
  width: 80%;
  height: NaNpx;
  border: 1px solid rgba(232, 232, 232, 1);
}
p0 {
  position: absolute;
  left: 410px;
  top: 500px;
  font-size: 13px;
  color: gray;
}
h2 {
  position: absolute;
  left: 400px;
  top: 140px;
  width: 100px;
  height: 38px;
  color: rgba(96, 96, 96, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}
p1 {
  position: absolute;
  left: 500px;
  top: 140px;
  width: 100px;
  height: 30px;
  color: rgba(25, 144, 255, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}

h3 {
  position: absolute;
  left: 900px;
  top: 140px;
  width: 100px;
  height: 38px;
  color: rgba(96, 96, 96, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}
p2 {
  position: absolute;
  left: 1000px;
  top: 140px;
  width: 530px;
  height: 30px;
  color: rgba(25, 144, 255, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}

h4{
  position: absolute;
  left: 400px;
  top: 240px;
  width: 100px;
  height: 38px;
  color: rgba(96, 96, 96, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}
p3 {
  position: absolute;
  left: 500px;
  top: 240px;
  width: 250px;
  height: 30px;
  color: rgba(25, 144, 255, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}

h5 {
  position: absolute;
  left: 900px;
  top: 240px;
  width: 120px;
  height: 38px;
  color: rgba(96, 96, 96, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}
p4 {
  position: absolute;
  left: 1000px;
  top: 240px;
  width: 250px;
  height: 30px;
  color: rgba(25, 144, 255, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}

h6 {
  position: absolute;
  left: 400px;
  top: 340px;
  width: 90px;
  height: 38px;
  color: rgba(96, 96, 96, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}
p5 {
  position: absolute;
  left: 500px;
  top: 340px;
  width: 250px;
  height: 30px;
  color: rgba(25, 144, 255, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}

h7 {
  position: absolute;
  left: 900px;
  top: 340px;
  width: 120px;
  height: 38px;
  color: rgba(96, 96, 96, 1);
  font-size: 20px;
  font-weight: bold;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}
p6 {
  position: absolute;
  left: 1000px;
  top: 340px;
  width: 250px;
  height: 30px;
  color: rgba(25, 144, 255, 1);
  font-size: 20px;
  text-align: left;
  font-family: SourceHanSansSC-regular;
}
button {
  position: absolute;
  left: 610px;
  top: 480px;
  width: 200px;
  height: 50px;
  background-color: rgba(24, 144, 255, 1);
  border: none;
  border-radius: 12px;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 18px;
  margin: 4px 2px;
  cursor: pointer;
  font-family: PingFangSC-regular;
}
</style>
